package com.hq.ims.data.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.BusInfoFeedback;
import com.hq.ims.data.entityenum.EnumBusinessTypeStatus;
import com.hq.ims.data.entityenum.EnumFeedbackPhase;
import com.hq.ims.data.entityenum.EnumProjectPhase;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20241024
 */
@Mapper
public interface BusInfoFeedbackMapstruct {

    BusInfoFeedbackMapstruct INSTANCE = Mappers.getMapper(BusInfoFeedbackMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    BusInfoFeedbackVo toBusInfoFeedbackVo(BusInfoFeedback source);

    default List<BusInfoFeedbackVo> toBusInfoFeedbackVoList(List<BusInfoFeedback> source){
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toBusInfoFeedbackVo).collect(Collectors.toList());
    }

    @Mappings({
    })
    FeedbackDetailVo toFeedbackDetailVo(BusInfoFeedback source);

    default List<FeedbackDetailVo> toFeedbackDetailVoList(List<BusInfoFeedback> source){
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toFeedbackDetailVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class BusInfoFeedbackVo extends BusInfoFeedback {
        
    }

    @ApiModel(value = "反馈详情VO")
    @Data
    class FeedbackDetailVo {

        @ApiModelProperty(value = "反馈id")
        private String busInfoFeedbackId;

        @ApiModelProperty(value = "反馈时间")
        @JSONField(format = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime feedbackDate;

        @ApiModelProperty(value = "反馈阶段")
        private EnumFeedbackPhase feedbackPhase;

        @ApiModelProperty(value = "反馈内容")
        private String content;

        @ApiModelProperty(value = "是否有反馈文件标识")
        private Boolean feedbackFileFlag;

        @ApiModelProperty(value = "反馈内容文件列表")
        private List<AppFileMapstruct.FileVo> fileVoList;

        @ApiModelProperty(value = "产业标记")
        private String industryMarkName;

        @ApiModelProperty(value = "经营人员名称")
        private String busiPersonName;

        @ApiModelProperty(value = "派生的经营信息数量")
        private Integer deriveBusiInfoCount;

        @ApiModelProperty(value = "派生经营信息列表")
        private List<DeriveBusiInfoVo> deriveBusiInfoList;
    }

    @ApiModel(value = "派生的经营信息VO")
    @Data
    class DeriveBusiInfoVo {

        @ApiModelProperty(value = "数据id")
        private String busInfoFeedbackDeriveId;

        @ApiModelProperty(value = "经营信息id")
        private String busiInfoId;

        @ApiModelProperty(value = "项目名称")
        private String projectName;

        @ApiModelProperty(value = "信息类型")
        private EnumBusinessTypeStatus infoType;

        @ApiModelProperty(value = "项目阶段")
        private EnumProjectPhase projectStage;

        @ApiModelProperty(value = "省份")
        private String province;

        @ApiModelProperty(value = "城市")
        private String city;

        @ApiModelProperty(value = "产业标记")
        private String industryAssign;

        @ApiModelProperty(value = "发布时间")
        private LocalDateTime publishTime;

        @ApiModelProperty(value = "预计产值规模")
        private BigDecimal outputScale;
    }


    @ApiModel(value = "行级权限对象")
    @Data
    class BusInfoFeedbackRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限


        //构造函数
        public BusInfoFeedbackRowAuthVo(BusInfoFeedback entity){
            //当前操作用户ID
            String userId = AppUtils.getUserId();
        }
        
    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String busInfoFeedbackId;

        @ApiModelProperty(value = "经营信息跟踪ID")
        private String busInfoTrackId;

        @NotNull(message = "反馈阶段不能为空")
        @ApiModelProperty(value = "反馈阶段")
        private EnumFeedbackPhase feedbackPhase;

        @NotBlank(message = "反馈内容不能为空")
        @ApiModelProperty(value = "反馈内容")
        private String content;

        @ApiModelProperty(value = "反馈文件(选填)")
        private List<AppFileMapstruct.FileVo> fileVoList;

        @ApiModelProperty(value = "派生经营信息")
        private List<BusiInfoMapstruct.SaveVo> deriveBusiInfoList;
    }

    //-------------------------------- springboot验证标识 --------------------------------

}
